package com.baitiaojun.api.util;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @类名 SpringContextUtil
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2023/1/28 12:05
 * @版本 1.0
 */
@Component
public class SpringContextUtil {

    private static ApplicationContext applicationContext;

    public static void setApplicationContext(ApplicationContext context) {
        applicationContext = context;
    }

    public static <T> T getBean(Class<T> clazz) {
        return applicationContext.getBean(clazz);
    }

    public static <T> T getBean(String beanName, Class<T> clazz) {
        return applicationContext.getBean(beanName, clazz);
    }
}
